<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@ page import="model.*,util.*,bll.*"%>
<%
	PhaseModel obj;
	Object temp = request.getAttribute("phase");
	if (temp != null) {
		try {
			obj = (PhaseModel) temp;
		} catch (Exception ex) {
			obj = new PhaseModel();
		}
	} else {
		obj = new PhaseModel();
	}
	int idProject = obj.getIdProject();
	String projectName = CacheUtil.getProjectName(idProject);
	String projectUrl = "project.jsp?id=" + idProject;
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Edit Phase</title>

<link rel="stylesheet" href="css/common.css" />
<link rel="stylesheet" href="css/inputForm.css" />
<link rel="stylesheet" href="css/listForm.css" />
<link rel="stylesheet" href="css/jquery-ui-1.8.14.custom.css" type="text/css" />
<link rel="stylesheet" href="css/hyjack.css" type="text/css" />
<link rel="stylesheet" href="css/datepicker.css" type="text/css" />
<link rel="stylesheet" href="css/themes/ui-lightness/jquery.ui.all.css" />
<link rel="stylesheet" href="css/jquery-ui-timepicker.css" type="text/css" />
<link rel="stylesheet" href="css/jquery-datepicker.css" />
<link rel="stylesheet" href="css/jquery-dialog.css" />

<script language="javascript" type="text/javascript" src="js/jquery.min.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.hyjack.select.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.ui.core.min.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.ui.widget.min.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.ui.timepicker.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.ui.datepicker.js"></script>
<script language="javascript" type="text/javascript" src="js/datepicker.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.hyjack.js"></script>
<script language="javascript" type="text/javascript" src="js/ajaxQuickInsert.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.ui.tools.min.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.numeric.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.14.custom.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-timepicker-addon.js"></script>
<script language="javascript" type="text/javascript" src="js/common.js"></script>


<link rel="stylesheet" href="css/inputForm.css" />

<script language="javascript" type="text/javascript">
	$(document).ready(pageLoaded);
	function pageLoaded()
	{
		turnOnNumbericInput();
		initTooltip();
	}

	var requiredInputs = [['name','name_required'], ['index','index_required']];
	//var requiredInputs = [['name','name_required'], ['plan_start_date','plan_start_date_required'], ['plan_end_date','plan_end_date_required']
	//['real_start_date','real_start_date_required'], ['real_end_date','real_end_date_required']];
	//var intInputs = [];
	//var doubleInputs = [];
	//var dateInputs = [['plan_start_date','plan_start_date_invalid'],['plan_end_date','plan_end_date_invalid'],['real_start_date','real_start_date_invalid'],['real_end_date','real_end_date_invalid']];
	//var timeInputs = [];
	
	function checkInputs() {
		var valid = true;
	
		if (checkRequiredInputs(requiredInputs) == false) {
			valid = false;
		}
		//if (checkIntInputs(intInputs) == false) {
		//valid = false;
		//}
		//if (checkDoubleInputs(doubleInputs) == false) {
		//valid = false;
		//}
// 		if (checkDateInputsForCorrectedFormatOnly(dateInputs, dateFormat) == false) {
// 			valid = false;
// 		}
		//if (checkTimeInputs(timeInputs) == false) {
		//valid = false;
		//}
		
		// SPECIFIC VALIDATE CODE HERE		
		
		return valid;
	}
</script>
</head>
<body>
	<div class="divContainer">
		<%@ include file="menu.jsp"%>
		<form id="inputForm" action="phase?mode=update&id_project=<%=idProject%>" method="post" onSubmit="return checkInputs()" onreset="return confirm('Do you really want to reset the form?')">
			<table class="tblInput">
				<tr>
					<td colspan="3"><b>Project: <a id="link_project" name="link_project" href="<%=projectUrl%>"><%=projectName%></a> </b></td>
				</tr>
				<tr>
					<td class="inputHeader">Edit Phase</td>
				</tr>
				<tr>
					<td style="padding-left: 400px; padding-right: 400px;">
						<table cellspacing="0px">
						<tr class="trField">
							<td class="tdFieldName">Id</td>
							<td class="tdFieldInput"><input class="inputInt readonly" type="text" id="id" name="id" readonly="readonly" value="<%=obj.getId()%>" title="Phase ID. It's readonly."/></td>
							<td class="tdErrMsg"></td>
						<tr class="trField">
							<td class="tdFieldName">Name</td>
							<td class="tdFieldInput"><input class="inputText" type="text" id="name" name="name" maxlength="255" value="<%=obj.getName()%>" title="Phase name"  onblur="validateRequiredInput('name');"/></td>
							<td class="tdErrMsg">
								<span id="name_required" class="errMsg" style="display: none;" title="Name is a required field.">(!)</span> 
								<span id="name_error" class="errMsg"><%=obj.errMsgs.Name%></span>
							</td>
						</tr>
						<!-- 						<tr class="trField"> -->
						<!-- 							<td class="tdFieldName">Code</td> -->
						<%-- 							<td class="tdFieldInput"><input class="inputText" type="text" id="code" name="code" maxlength="20" value="<%=obj.getCode()%>" /> --%>
						<!-- 							</td> -->
						<%-- 							<td class="tdErrMsg"><span id="code_required" class="errMsg" style="display: none;">Code is required</span> <span id="code_invalid" class="errMsg" style="display: none;">Code is invalid</span> <span id="code_error" class="errMsg"><%=obj.errMsgs.Code%></span> --%>
						<!-- 							</td> -->
						<!-- 						</tr> -->
						<tr class="trField">
							<td class="tdFieldName">Index</td>
							<td class="tdFieldInput"><input class="inputInt" type="text" id="index" name="index" maxlength="10" title="Phase index. <b>Note:</b> Integer only." onblur="validateRequiredInput('index');" value="<%=obj.getIndexToString()%>"/>
							</td>
							<td class="tdErrMsg">
								<span id="index_required" class="errMsg" style="display: none;" title="Index is a required field.">(!)</span> 
								<span id="index_error" class="errMsg" title="<%=obj.errMsgs.Index%>"></span>
							</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Description</td>
							<td class="tdFieldInput"><textarea id="description" name="description" rows="5" class="inputTextarea" title="Description of the phase"><%=obj.getDescriptionToString()%></textarea></td>
							<td class="tdErrMsg">
							</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Remark</td>
							<td class="tdFieldInput"><textarea id="remark" name="remark" rows="5" class="inputTextarea" title="Remark of phase."><%=obj.getRemark() %></textarea></td>
							<td class="tdErrMsg"></td>
						</tr>
<!-- 						<tr class="trField"> -->
<!-- 							<td class="tdFieldName">Status</td> -->
<!-- 							<td class="tdFieldInput"><select id="status" name="status" class="hyjack" title="Click to choose phase status"> -->
<%-- 									<%=HtmlUtil.genEnumSelect(EnumName.PhaseStatus, null, obj.getStatus())%> --%>
<!-- 							</select> -->
<!-- 							</td> -->
<%-- 							<td class="tdErrMsg"><span id="status_required" class="errMsg" style="display: none;">Status is required</span> <span id="status_invalid" class="errMsg" style="display: none;">Status is invalid</span> <span id="status_error" class="errMsg"><%=obj.errMsgs.Status%></span></td> --%>
<!-- 						</tr> -->
<!-- 						<tr class="trField"> -->
<!-- 							<td class="tdFieldName">Plan Start Date</td> -->
<%-- 							<td class="tdFieldInput"><input type="text" maxlength="10" class="inputDate" id="plan_start_date" name="plan_start_date" title="Click to choose plan start date" value="<%=StringUtil.toDateString(obj.getPlanStartDate()) %>"  onblur="validateDateInput('plan_start_date', true);"/> <span class="textGuide">(dd/mm/yyyy)</span> <!-- 								<table class="tblDateTime"> --> <!-- 									<tr class="trDateTime"> --> <!-- 										<td class="tdDate"> --> <!-- 										<input type="text" maxlength="10" class="inputDate" id="plan_start_date" name="plan_start_date" title="Click to choose plan start date" />  --> <!-- 										<span class="textGuide">(dd/mm/yyyy)</span> --> <!-- 										</td> --> 										<td class="tdTime"><input type="text" maxlength="5" class="inputTime" id="plan_start_date_time" name="plan_start_date_time" value="<%=obj.getPlanStartDate()%>" /> <!-- 										</td> --> <!-- 									</tr> --> <!-- 								</table>  --></td> --%>
<%-- 							<td class="tdErrMsg"><span id="plan_start_date_error" class="errMsg"><%=obj.errMsgs.PlanStartDate%></span> --%>
<!-- 									<span id="plan_start_date_required" class="errMsg" style="display: none;"title="Plan start date is required">(!)</span> -->
<%-- 									<span id="plan_start_date_invalid" class="errMsg" style="display: none;" title="You've entered an invalid date. The format should be <b>dd/mm/yyyy</b>">(!)</span>									 --%>
<!-- 							</td> -->
<!-- 						</tr> -->
<!-- 						<tr class="trField"> -->
<!-- 							<td class="tdFieldName">Plan End Date</td> -->
<%-- 							<td class="tdFieldInput"><input type="text" maxlength="10" class="inputDate" id="plan_end_date" name="plan_end_date" title="Click to choose plan end date" value="<%=StringUtil.toDateString(obj.getPlanEndDate()) %>" onblur="validateDateInput('plan_end_date', true);"/> <span class="textGuide">(dd/mm/yyyy)</span> --%>
<%-- 							<td class="tdErrMsg"><span id="plan_end_date_error" class="errMsg"><%=obj.errMsgs.PlanEndDate%></span> --%>
<!-- 								<span id="plan_end_date_required" class="errMsg" style="display: none;" title="Plan end date is required">(!)</span> -->
<%-- 								<span id="plan_end_date_invalid" class="errMsg" style="display: none;" title="You've entered an invalid date. The format should be <b>dd/mm/yyyy</b>">(!)</span> --%>
<!-- 							</td> -->
<!-- 						</tr> -->
<!-- 						<tr class="trField"> -->
<!-- 							<td class="tdFieldName">Real Start Date</td> -->
<%-- 							<td class="tdFieldInput"><input type="text" maxlength="10" class="inputDate" id="real_start_date" name="real_start_date" title="Click to choose real start date" value="<%=StringUtil.toDateString(obj.getRealStartDate()) %>" onblur="validateDateInput('real_start_date', false);"/> <span class="textGuide">(dd/mm/yyyy)</span></td> --%>
<%-- 							<td class="tdErrMsg"><span id="real_start_date_error" class="errMsg"><%=obj.errMsgs.RealStartDate%></span> --%>
<!-- 								<span id="real_start_date_required" class="errMsg" style="display: none;" title="Real start date is required">(!)</span> -->
<%-- 								<span id="real_start_date_invalid" class="errMsg" style="display: none;" title="You've entered an invalid date. The format should be <b>dd/mm/yyyy</b>">(!)</span> --%>
<!-- 							</td> -->
<!-- 						</tr> -->
<!-- 						<tr class="trField"> -->
<!-- 							<td class="tdFieldName">Real End Date</td> -->
<%-- 							<td class="tdFieldInput"><input type="text" maxlength="10" class="inputDate" id="real_end_date" name="real_end_date" title="Click to choose real end date" value="<%=StringUtil.toDateString(obj.getRealEndDate()) %>" onblur="validateDateInput('real_end_date', false);"/> <span class="textGuide">(dd/mm/yyyy)</span> <!-- 								<table class="tblDateTime"> --> <!-- 									<tr class="trDateTime"> --> <!-- 										<td class="tdDate"><input type="text" maxlength="10" class="inputDate" id="real_end_date_date" name="real_end_date_date" /> <input type="button" class="btnCalendar" value="..." onclick="javascript:displayDatePicker('real_end_date', this, dateFormat);" /> --> <!-- 										</td> --> <!-- 										<td class="tdTime"><input type="text" maxlength="5" class="inputTime" id="real_end_date_time" name="real_end_date_time" /> --> <!-- 										</td> --> <!-- 									</tr> --> <!-- 								</table> --> --%>
<!-- 							</td> -->
<%-- 							<td class="tdErrMsg"><span id="real_end_date_error" class="errMsg"><%=obj.errMsgs.RealEndDate%></span> --%>
<!-- 								<span id="real_end_date_required" class="errMsg" style="display: none;" title="Real end date is required">(!)</span> -->
<%-- 								<span id="real_end_date_invalid" class="errMsg" style="display: none;" title="You've entered an invalid date. The format should be <b>dd/mm/yyyy</b>">(!)</span> --%>
<!-- 							</td> -->
<!-- 						</tr> -->
						<tr class="trInputBottom">
							<td class="tdFieldName"></td>
							<td class="tdSubmit"><input class="btnSubmit" type="submit" value="Submit" title="Click to save above information."/></td>
<!-- 							<td></td> -->
<!-- 							<td class="tdInputBottom" colspan="2"> -->
<!-- 								<table class="tblSubmit" align="left"> -->
<!-- 									<tr class="trSubmit"> -->
<!-- 										<td class="tdSubmit" style="padding-left: 0px"><input class="btnSubmit" type="submit" value="Submit" title="Click to save above information."/></td> -->
<!-- 									</tr> -->
<!-- 								</table></td> -->
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</form>
	<%
		String str = "phaseList.jsp?embedded=true&idProject=" + obj.getIdProject();
	%>
	<jsp:include page="<%=str %>"></jsp:include>
	</div>
</body>
</html>